package com.ganlebao.study.springcloudribbon.basic.ribbonconfig;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import com.netflix.loadbalancer.Server;
import com.netflix.loadbalancer.ServerList;
import org.springframework.cloud.netflix.ribbon.StaticServerList;
import org.springframework.context.annotation.Bean;

//@Configuration
public class RibbonConfig {
    /**
     * 轮询策略
     *
     * @return
     */
    @Bean
    public IRule ribbonRule() {
        return new RoundRobinRule();
    }

    @Bean
    public ServerList<Server> serverList() {
        Server server1 = new Server( "127.0.0.1", 8090);
        Server server2 = new Server( "127.0.0.1", 8091);
        return new StaticServerList<>(server1, server2);
    }


}
